package com.djakapm.swing.component;

import javax.swing.*;
import java.awt.event.KeyListener;

public class EditorPaneView extends JScrollPane{
    private JEditorPane editorPane;

    public EditorPaneView(){
        this.editorPane = new JEditorPane();
        this.getViewport().setView(this.editorPane);
        this.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_AS_NEEDED);
        this.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_AS_NEEDED);
    }

    public String getText(){
        return this.editorPane.getText();
    }

    public void setText(String text){
        this.editorPane.setText(text);
    }

    public JEditorPane getComponent(){
        return this.editorPane;
    }

    public void addKeyListener(KeyListener listener){
        this.editorPane.addKeyListener(listener);
    }
}
